<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <link rel="stylesheet" href="/study/style/style.css">
<script>
    var NlviConfig = {
        title: "子鱼非鱼",
        author: "张春园",
        theme: "banderole",
        lightbox: true,
        animate: true,
        baseUrl: "/study/",
        search: false
    }
</script>



    <link rel="stylesheet" href="/study/script/lib/lightbox/css/lightbox.min.css">




    <link rel="stylesheet" href="/study/syuanpi/syuanpi.min.css">




    <link rel="icon" href="http://img.blog.csdn.net/20180117154531985?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmFpZHVfMzMyOTc3MjA=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">







<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="browsermode" content="application">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="子鱼非鱼">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="msapplication-navbutton-color" content="#666666">
<meta name= "format-detection" content="telephone=no" />
<meta name="keywords" content="nlvi, Nlvi" />

  <link rel="apple-touch-icon"  sizes="72x72"  href="http://img.blog.csdn.net/20180117154531985?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmFpZHVfMzMyOTc3MjA=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
  <link rel="apple-touch-icon-precomposed"  sizes="72x72"  href="http://img.blog.csdn.net/20180117154531985?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmFpZHVfMzMyOTc3MjA=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">


  <meta name="subtitle" content="每一次抬脚，每一次落步，它代表一种进步，时间最无情，我们需要让每一步都跟得上时间的节奏！">


  <meta name="description" content="子鱼非鱼">



  <meta name="keywords" content="Maven, Nlvi" />

  <title> 使用Maven放入本地Jar包，并打进war包 · 子鱼非鱼 </title>
</head>
<body>
  <div class="progress">
  <div class="progress-inner"></div>
</div>
  
  
    <div class="tagcloud-mask"></div>  
<div class="tagcloud" id="tagcloud">
  <div class="tagcloud-inner">
    <a href="/study/tags/Annotation/" style="font-size: 14px;">Annotation</a> <a href="/study/tags/HelloWorld/" style="font-size: 14px;">HelloWorld</a> <a href="/study/tags/Maven/" style="font-size: 14px;">Maven</a>
  </div>
</div>  
  

  <div class="container">

    <header class="header" id="header">
  <div class="header-wrapper">
    <div class="logo">
  <div class="logo-inner syuanpi tvIn">
    <span><a href="/study/">子鱼非鱼</a></span>
    
      <span id="subtitle">每一次抬脚，每一次落步，它代表一种进步，时间最无情，我们需要让每一步都跟得上时间的节奏！</span>
    
  </div>
</div>
    <nav class="main-nav">
        
  <ul class="main-nav-list syuanpi tvIn">
  
  
    
      
    
    <li class="menu-item">
      <a href="/study/" id="article">
        <span class="base-name">文章</span>
        
          <span class="menu-item-label">article</span>
        
      </a>
    </li>  
  
    
      
    
    <li class="menu-item">
      <a href="/study/archives" id="archives">
        <span class="base-name">归档</span>
        
          <span class="menu-item-label">archives</span>
        
      </a>
    </li>  
  
    
      
    
    <li class="menu-item">
      <a href="javascript:;" id="tags">
        <span class="base-name">标签</span>
        
          <span class="menu-item-label">tags</span>
        
      </a>
    </li>  
  
    
      
    
    <li class="menu-item">
      <a href="/study/about" id="about">
        <span class="base-name">关于</span>
        
          <span class="menu-item-label">about</span>
        
      </a>
    </li>  
  
  </ul>
  
</nav>
    
    
  </div>
</header>
<div class="mobile-header">
  <div class="mobile-header-body">
    <div class="mobile-header-list">
      
        
            <div class="mobile-nav-item">
                <a href="/study/">
                    <span>文章</span>
                    
                        <span class="menu-item-label">article</span>
                    
                </a>
            </div>
        
      
        
            <div class="mobile-nav-item">
                <a href="/study/archives">
                    <span>归档</span>
                    
                        <span class="menu-item-label">archives</span>
                    
                </a>
            </div>
        
      
        
          <div class="mobile-nav-item inner-cloud">
            <div class="mobile-nav-tag">
              <a href="javascript:;" id="mobile-tags">
                <span>标签</span>
                
                    <span class="menu-item-label">tags</span>
                
              </a>
            </div>
            <div class="mobile-nav-tagcloud">
              <div class="mobile-tagcloud-inner">
                <a href="/study/tags/Annotation/" style="font-size: 14px;">Annotation</a> <a href="/study/tags/HelloWorld/" style="font-size: 14px;">HelloWorld</a> <a href="/study/tags/Maven/" style="font-size: 14px;">Maven</a>
              </div>
            </div>
          </div>
        
      
        
            <div class="mobile-nav-item">
                <a href="/study/about">
                    <span>关于</span>
                    
                        <span class="menu-item-label">about</span>
                    
                </a>
            </div>
        
      
    </div>
  </div>
  <div class="mobile-header-nav">
    <div class="mobile-header-item" id="mobile-left">
      <div class="header-menu-item">
        <span class="header-menu-line"></span>
      </div>
    </div>
    <h1 class="mobile-header-title">
      <a href="/">子鱼非鱼</a>
    </h1>
    <div class="mobile-header-item"></div>
  </div>
</div>
    <div class="container-inner">
      <main class="main" id="main">
        <div class="main-wrapper">
          
    
  <article class="
  post
   is_post 
  ">
    <header class="post-header">
      <div class="post-time syuanpi riseIn-light back-1">
        <div class="post-time-wrapper">
          <span>2018-01-22</span>
          
          
            
              <aside class="post-tags syuanpi riseIn-light back-3">
              
                <a href="/study/tags/Maven/">Maven</a>
              
              </aside>
            
          
        </div>
      </div>
      <h1 class="post-title syuanpi riseIn-light back-2">
        
          使用Maven放入本地Jar包，并打进war包
        
      </h1>
    </header>
    <div class="post-content syuanpi riseIn-light back-3">
      
        <p>项目开发接触了Maven，发现一些第三方Jar包在Maven Repository 中不存在，于是用了最原始的方法，结果发现程序根本无法运行起来，后来通过百度总算搞定了。</p>
<a id="more"></a>
<h3 id="加入本地-jar-包"><a href="#加入本地-jar-包" class="headerlink" title="加入本地  jar 包"></a>加入本地  jar 包</h3><ol>
<li>在项目根目录下创建 lib 文件夹。</li>
<li>加入本地 jar 包<br><img src="http://img.blog.csdn.net/20180122113703906?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmFpZHVfMzMyOTc3MjA=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="加入本地 jar 包"></li>
</ol>
<h3 id="修改-pom-xml-文件"><a href="#修改-pom-xml-文件" class="headerlink" title="修改 pom.xml 文件"></a>修改 pom.xml 文件</h3><p><img src="http://img.blog.csdn.net/20180122113905332?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmFpZHVfMzMyOTc3MjA=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="pom.xml文件修改"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">&lt;dependency&gt;</span><br><span class="line">	  &lt;groupId&gt;net.esign&lt;/groupId&gt;</span><br><span class="line">	  &lt;artifactId&gt;tech-sdk&lt;/artifactId&gt;</span><br><span class="line">	  &lt;version&gt;2.0.18&lt;/version&gt;</span><br><span class="line">	  &lt;scope&gt;system&lt;/scope&gt;</span><br><span class="line">	  &lt;systemPath&gt;$&#123;basedir&#125;/lib/tech-sdk-2.0.18.jar&lt;/systemPath&gt;</span><br><span class="line">	&lt;/dependency&gt;</span><br><span class="line">	</span><br><span class="line">	&lt;dependency&gt;</span><br><span class="line">	  &lt;groupId&gt;net.esign&lt;/groupId&gt;</span><br><span class="line">	  &lt;artifactId&gt;tgtext&lt;/artifactId&gt;</span><br><span class="line">	  &lt;version&gt;3.2.0&lt;/version&gt;</span><br><span class="line">	  &lt;scope&gt;system&lt;/scope&gt;</span><br><span class="line">	  &lt;systemPath&gt;$&#123;basedir&#125;/lib/tgtext-3.2.0.jar&lt;/systemPath&gt;</span><br><span class="line">	&lt;/dependency&gt;</span><br><span class="line">	</span><br><span class="line">	&lt;dependency&gt;</span><br><span class="line">	  &lt;groupId&gt;net.esign&lt;/groupId&gt;</span><br><span class="line">	  &lt;artifactId&gt;utils&lt;/artifactId&gt;</span><br><span class="line">	  &lt;version&gt;3.0.6-SNAPSHOT&lt;/version&gt;</span><br><span class="line">	  &lt;scope&gt;system&lt;/scope&gt;</span><br><span class="line">	  &lt;systemPath&gt;$&#123;basedir&#125;/lib/utils-3.0.6-SNAPSHOT.jar&lt;/systemPath&gt;</span><br><span class="line">	&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<ol>
<li>这里的 groupId , artifactId 可以随便填写。</li>
<li>scope 填写system(这里固定写法)。</li>
<li>${basedir} 是指项目根路径。</li>
</ol>
<p>保存之后会发现之前加入的 jar 包变成了这样。</p>
<p><img src="http://img.blog.csdn.net/20180122114126536?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmFpZHVfMzMyOTc3MjA=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="显示jar包"> </p>
<p>这说明在我们本地该 jar 包可以使用了，如果在修改 pom.xml 报错的话，可以 在项目上右键 –&gt; Maven – &gt; update project 。</p>
<h3 id="pom-xml-加入插件"><a href="#pom-xml-加入插件" class="headerlink" title="pom.xml 加入插件"></a>pom.xml 加入插件</h3><p>此时我们 jar 包在使用的时候是没有任何问题的，但是会发现，当我们把项目打成war包时，我们的 war 包下 WEB-INF\lib 中并没有这些 jar 包，所以我们需要在 pom.xml 中加入以下插件用于将本地 jar 包打入  war 包。</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">&lt;plugins&gt;</span><br><span class="line">	</span><br><span class="line">	&lt;!-- 用于把本地Jar打进war包 --&gt;</span><br><span class="line">	&lt;plugin&gt;</span><br><span class="line">		&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;</span><br><span class="line">		&lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;</span><br><span class="line">		&lt;version&gt;2.10&lt;/version&gt;</span><br><span class="line">		&lt;executions&gt;</span><br><span class="line">			&lt;execution&gt;</span><br><span class="line">				&lt;id&gt;copy-dependencies&lt;/id&gt;</span><br><span class="line">				&lt;phase&gt;compile&lt;/phase&gt;</span><br><span class="line">				&lt;goals&gt;</span><br><span class="line">					&lt;goal&gt;copy-dependencies&lt;/goal&gt;</span><br><span class="line">				&lt;/goals&gt;</span><br><span class="line">				&lt;configuration&gt;</span><br><span class="line">					&lt;outputDirectory&gt;$&#123;project.build.directory&#125;/$&#123;project.build.finalName&#125;/WEB-INF/lib&lt;/outputDirectory&gt;</span><br><span class="line">					&lt;includeScope&gt;system&lt;/includeScope&gt;</span><br><span class="line">				&lt;/configuration&gt;</span><br><span class="line">			&lt;/execution&gt;	</span><br><span class="line">		&lt;/executions&gt;</span><br><span class="line">	&lt;/plugin&gt;</span><br><span class="line"></span><br><span class="line">&lt;/plugins&gt;</span><br></pre></td></tr></table></figure>
<p>这样，就可以实现自己想要的样子了。</p>

      
    
    </div>
    
      
      
  <hr class="copy-line">
  <div class="post-copyright">
    <div class="copy-author">
      <span>作者 :</span>
      <span>张春园</span>
    </div>
    <div class="copy-url">
      <span>地址 :</span>
      <a href="http://wjzcy_hfh.gitee.io/study/2018/01/22/mavenincludelocal/">http://wjzcy_hfh.gitee.io/study/2018/01/22/mavenincludelocal/</a>
    </div>
    <div class="copy-origin">
      <span>来源 :</span>
      <a href="http://wjzcy_hfh.gitee.io/study">http://wjzcy_hfh.gitee.io/study</a>
    </div>
    <div class="copy-license">
      
      著作权归作者所有，转载请联系作者获得授权。
    </div>
  </div>

    
  </article>
  
    
  <nav class="article-page">
    
      <a href="/study/2018/01/22/PostConstruct/" id="art-left" class="art-left">
        <span class="next-title">
          <i class="iconfont icon-left"></i>注解@PostConstruct和@PreDestroy
        </span>
      </a>
    
    
      <a href="/study/2018/01/17/csdn-markdown/" id="art-right" class="art-right">
        <span class="prev-title"> 
          CSDN markdown编辑器写博客<i class="iconfont icon-right"></i>  
        </span>
      </a>
    
  </nav>

    
  <i id="com-switch" class="iconfont icon-more jumping-in long infinite" style="font-size:24px;display:block;text-align:center;transform:rotate(180deg);"></i>
  <div class="post-comments" id="post-comments" style="display: block;margin: auto 16px;">
    
    
    

  </div>


  
   
    
  
  <aside class="post-toc">
    <span class="title" id="toc-switch"><span>文章导航</span></span>
    <div class="toc-inner syuanpi back-1 fallIn-light">
      <li class="title-link"><a href="javascript:;" class="toTop">使用Maven放入本地Jar包，并打进war包</a></li>
      <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#加入本地-jar-包"><span class="toc-text">加入本地  jar 包</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#修改-pom-xml-文件"><span class="toc-text">修改 pom.xml 文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#pom-xml-加入插件"><span class="toc-text">pom.xml 加入插件</span></a></li></ol>
    </div>
  </aside>


  


        </div>
      </main>

      <footer class="footer syuanpi fadeIn" id="footer">
  <hr>
  <div class="footer-wrapper">
    <div class="left">
      <div class="contact-icon">
    
    
    
    
    
    
    
    
        
        
        
        
        
            <a href="https://www.facebook.com/" class="iconfont icon-facebook" title="facebook"></a>
        
        
        
    
        
        
        
            <a href="https://twitter.com/" class="iconfont icon-twitter" title="twitter"></a>
        
        
        
        
        
    
        
        
        
        
        
        
        
            <a href="https://www.instagram.com/" class="iconfont icon-ins" title="instagram"></a>
        
    
        
        
            <a href="https://weibo.com/3784582021" class="iconfont icon-weibo" title="weibo"></a>
        
        
        
        
        
        
    
        
        
        
        
            <a href="https://www.zhihu.com/people/zhang-chun-yuan-47-16" class="iconfont icon-zhihu" title="zhihu"></a>
        
        
        
        
    
        
            <a href="https://github.com/snow-ydss" class="iconfont icon-github" title="github"></a>
        
        
        
        
        
        
        
    
        
        
        
        
        
        
            <a href="https://www.linkedin.com/in/" class="iconfont icon-linkedin" title="linkedin"></a>
        
        
    
</div>
    </div>
    <div class="right">
      <div class="copyright">
    <div class="info">
        <span>&copy;</span>
        <span>2018 ~ 2018</span>
        <span>❤</span>
        <span>张春园</span>
    </div>
    <div class="theme">
        <span>
            动力来源于
            <a href="http://hexo.io/" target="_blank">Hexo </a>
        </span>
        <span>
            主题
            <a href="https://github.com/ColMugX/hexo-theme-Nlvi"> Nlvi </a>
        </span>
    </div>
    
</div>
    </div>
  </div>
</footer>
    </div>
  </div>
  <script src="/study/script/lib/jquery/jquery-3.2.1.min.js"></script>


    <script src="/study/script/lib/lightbox/js/lightbox.min.js"></script>






<script src="/study/script/src/nlvi.js"></script>
<script src="/study/script/src/utils.js"></script>
<script src="/study/script/scheme/balance.js"></script>
<script src="/study/script/src/plugins.js"></script>
<script src="/study/script/bootstarp.js"></script>


<div class="backtop syuanpi dead toTop" id="backtop">
    <i class="iconfont icon-up"></i>
    <span style="text-align:center;font-family:Georgia;"><span style="font-family:Georgia;" id="scrollpercent">1</span>%</span>
</div>


  

</body>
</html>
